package com.itheima.demo;

import com.itheima.config.SpringConfig;
import com.itheima.pojo.UserInfo;
import com.itheima.service.UserService;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.stereotype.Component;

@Component
public class Demo {
    public static void main(String[] args) {
        //1. 创建spring IOC容器
        ApplicationContext ac = new AnnotationConfigApplicationContext(SpringConfig.class);
        //2. 调用bean对象
        UserService userService = ac.getBean(UserService.class);
        //3. 调用service查询
        UserInfo userInfo = userService.findById(1);
        //4. 输出打印
        System.out.println(userInfo);
    }
}
